package cn.com.gome.sn.dubbo.bean;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;

/**
 * @ClassName: ParametersVo
 * @Description: dubbo服务接口方法请求回调Vo
 * @author mazhaohui-ds
 * @date 2016年1月7日 下午1:14:30
 */
public class SN_ParametersVo implements Serializable {

	private static final long serialVersionUID = -8886267161275214875L;

	/** 业务来源：01，PC端；02，移动端 */
	private String sources;

	/** 业务版本号，默认:0.1 */
	private String version = "0.1";

	/** 业务类型，与服务层服务类方法同名 */
	private String businessType;

	/** 业务参数集合 */
	private Map<String, Serializable> map = null;

	/** 错误码：0000,成功；0001,重复请求；0002,失败；其它错误码自定 */
	private String resCode;

	/** 错误信息，默认为“成功” */
	private String resDesc;

	/** 客户端IP */
	private String clientIp;

	public SN_ParametersVo() {
		this.map = new HashMap<String, Serializable>();
		this.clientIp = getClientIp();
	}

	public SN_ParametersVo(String sources) {
		this.sources = sources;
		map = new HashMap<String, Serializable>();
	}

	public SN_ParametersVo(String sources, String businessType) {
		this.sources = sources;
		this.businessType = businessType;
		map = new HashMap<String, Serializable>();
	}

	/** 业务来源：01，PC端；02，移动端 */
	public String getSources() {
		return sources;
	}

	/** 业务来源：01，PC端；02，移动端 */
	public void setSources(String sources) {
		this.sources = sources;
	}

	/** 业务版本号，默认:0.1 */
	public String getVersion() {
		return version;
	}

	/** 业务版本号，默认:0.1 */
	public void setVersion(String version) {
		this.version = version;
	}

	/** 业务类型，与服务层服务类方法同名 */
	public String getBusinessType() {
		return businessType;
	}

	/** 业务类型，与服务层服务类方法同名 */
	public void setBusinessType(String businessType) {
		this.businessType = businessType;
	}

	/** 业务参数 */
	public void setInfo(String key, String value) {
		map.put(key, value);
	}

	/** 业务参数 */
	public Object getInfo(String key) {
		return map.get(key);
	}

	/** 业务参数 */
	public String getString(String key) {
		return (String) map.get(key);
	}

	@Override
	public String toString() {
		StringBuffer resultStr = new StringBuffer();
		resultStr.append(" businessType: " + this.getBusinessType());
		resultStr.append(" sources: " + this.getSources());
		resultStr.append(" version: " + this.getVersion());
		if (!StringUtils.isEmpty(this.getResCode())) {
			resultStr.append(" resCode: " + this.getResCode());
			resultStr.append(" resDesc: " + this.getResDesc());
		}
		resultStr.append(" map: " + this.map.toString());
		return resultStr.toString();

	}

	/** 错误码：0000,成功；0001,重复请求；0002,失败；其它错误码自定 */
	public String getResCode() {
		return resCode;
	}

	/** 错误码：0000,成功；0001,重复请求；0002,失败；其它错误码自定 */
	public void setResCode(String resCode) {
		this.resCode = resCode;
	}

	/** 错误信息，默认为“成功” */
	public String getResDesc() {
		return resDesc;
	}

	/** 错误信息，默认为“成功” */
	public void setResDesc(String resDesc) {
		this.resDesc = resDesc;
	}

	private String getClientIp() {
		return clientIp;
	}

	public void setClientIp(String clientIp) {
		this.clientIp = clientIp;
	}
}
